package com.sikao.app.ui;

import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.Gravity;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;

import com.cnzhizi.wheelpop.model.OneModel;
import com.cnzhizi.wheelpop.ui.SkmModiPopup;
import com.sikao.app.R;
import com.sikao.app.adapter.GvAddStepPricesTypeProfilePicItemAdapter;
import com.sikao.app.adapter.MllAddStepPricesTypeFiveItemAdapter;
import com.sikao.app.adapter.MllAddStepPricesTypeFourItemAdapter;
import com.sikao.app.adapter.MllAddStepPricesTypeOneItemAdapter;
import com.sikao.app.adapter.MllAddStepPricesTypeThreeItemAdapter;
import com.sikao.app.bean.AddGoodsStepTwoSubmitBean;
import com.sikao.app.bean.Bean;
import com.sikao.app.bean.CategoryAttrBean;
import com.sikao.app.bean.GetImageInfoBean;
import com.sikao.app.bean.GetImageInfoSubmitBean;
import com.sikao.app.bean.ReadAddGoodsStepTwoSubmitBean;
import com.sikao.app.bean.UploadPicturesBean;
import com.sikao.app.dao.AddGoodsStepTwoModel;
import com.sikao.app.dao.CategoryAttrModel;
import com.sikao.app.dao.GetImageInfoModel;
import com.sikao.app.dao.UploadPicturesModel;
import com.sikao.app.myinterface.Callback;
import com.sikao.app.net.HttpApi;
import com.sikao.app.net.OnNetBackListener;
import com.sikao.app.ui.base.BaseActivity;
import com.sikao.app.utils.JSONUtil;
import com.sikao.app.utils.Utils;
import com.sikao.app.view.MyGridView;
import com.sikao.app.view.MyListView;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by Sun on 2016/8/6.
 * [46]发布商品[step-2]  属性类型 1文本 2多行文本 3单选 4多选 5下拉 6文件
 */
public class AddGoodsStepTwoActivityOLD extends BaseActivity implements View.OnClickListener {

	private TextView titleTv;
	private TextView title_right_tv;
	private TextView title_left_tv;
	private ImageView backIv;
	private UploadPicturesModel uploadPicturesModel;
	private MyListView mllAddStepPricesTypeOne;
	private MyListView mllAddStepPricesTypeThree;
	private MyListView mllAddStepPricesTypeFour;
	private MyListView mllAddStepPricesTypeFive;
	private MyGridView gvAddStepPricesTypeProfilePic;

	AddGoodsStepTwoSubmitBean addGoodsStepTwoSubmitBean = new AddGoodsStepTwoSubmitBean();


	public static final int REQUEST_GET_PHOTO = 1001;
	int addTo;
	String catId;//分类ID
	String objectId;//商品ID
	int releaseGoodsState = 1;//编辑状态
	private String goodsStatus = "";
	public static boolean canEdit = true;
	String profilePic = "";//货物图样的照片的id

	CategoryAttrBean categoryAttrBean;//商品分类属性 这里修改成 [51-86]读取发布商品[step-2]
	MllAddStepPricesTypeOneItemAdapter mllAddStepPricesTypeOneItemAdapter;//文本的适配器
	MllAddStepPricesTypeThreeItemAdapter mllAddStepPricesTypeThreeItemAdapter;//单选的适配器 嵌套
	MllAddStepPricesTypeFourItemAdapter mllAddStepPricesTypeFourItemAdapter;//多选的适配器 嵌套
	MllAddStepPricesTypeFiveItemAdapter mllAddStepPricesTypeFiveItemAdapter;//下拉的适配器 嵌套

	GvAddStepPricesTypeProfilePicItemAdapter gvAddStepPricesTypeProfilePicItemAdapter;//货物图样适配器

	public static boolean initFlagTypeThree = false;//用于标识处理默认是否已经成功执行过一次 单选的赋值默认
	public static boolean initFlagTypeFour = false;//用于标识处理默认是否已经成功执行过一次 多选的赋值默认

	public static List<CategoryAttrBean.ResBean.AttrBean> resTypeOne = new ArrayList<>();//1文本
	public static List<CategoryAttrBean.ResBean.AttrBean> resTypeThree = new ArrayList<>();//3单选
	public static List<CategoryAttrBean.ResBean.AttrBean> resTypeFour = new ArrayList<>();//4多选
	public static List<CategoryAttrBean.ResBean.AttrBean> resTypeFive = new ArrayList<>();//5下拉

	private List<String> profilePicList = new ArrayList<String>();//货物图样
	int picIndex = 0;//点击的图片的下标


	@Override
	protected void onCreate(Bundle savedInstanceState) {
		setContentView(R.layout.activity_add_goods_step_two);
		super.onCreate(savedInstanceState);
	}

	@Override
	protected void initData() {
		/*
        (商品的状态goodsStatus)status:0.1不可编辑; status:-1.2可编辑 ;这是发布商品那边的
        新增状态 -1准备资料0待审核 1通过 2审核失败3下架4售空
              0,1,3,4 不可编辑
         */
		Intent intent = getIntent();
		addTo = intent.getIntExtra("addTo", 0);//addTo":[{"id":0,"value":"商城"},{"id":1,"value":"拍卖"},{"id":2,"value":"定向单"}]
		catId = intent.getStringExtra("catId");
		objectId = intent.getStringExtra("objectId");
		releaseGoodsState = intent.getIntExtra("releaseGoodsState", 1);
		goodsStatus = intent.getStringExtra("goodsStatus");

		if ("0".equals(goodsStatus) || "1".equals(goodsStatus) || "3".equals(goodsStatus) || "4".equals(goodsStatus)) {
			canEdit = false;
		} else if ("-1".equals(goodsStatus) || "2".equals(goodsStatus)) {
			canEdit = true;
		} else if ("3".equals(releaseGoodsState)) {
			canEdit = true;
		}

		Utils.showLog("=======addTo:" + addTo + " catId:" + catId + " objectId:" + objectId);
		//清空值
		categoryAttrBean = null;
		resTypeOne.clear();
		resTypeThree.clear();
		resTypeFour.clear();
		resTypeFive.clear();
		initFlagTypeThree = false;//用于标识处理默认是否已经成功执行过一次 单选的赋值默认
		initFlagTypeFour = false;//用于标识处理默认是否已经成功执行过一次 多选的赋值默认

	}

	@Override
	protected void initView() {
		titleTv = (TextView) findViewById(R.id.title_middle_tv);
		title_right_tv = (TextView) findViewById(R.id.title_right_tv);
		title_left_tv = (TextView) findViewById(R.id.title_left_tv);

		mllAddStepPricesTypeOne = (MyListView) findViewById(R.id.mll_add_step_prices_type_one);
		mllAddStepPricesTypeThree = (MyListView) findViewById(R.id.mll_add_step_prices_type_three);
		mllAddStepPricesTypeFour = (MyListView) findViewById(R.id.mll_add_step_prices_type_four);
		mllAddStepPricesTypeFive = (MyListView) findViewById(R.id.mll_add_step_prices_type_five);
		gvAddStepPricesTypeProfilePic = (MyGridView) findViewById(R.id.gv_add_step_prices_type_profile_pic);
		backIv = (ImageView) findViewById(R.id.title_left_img);


		gvAddStepPricesTypeProfilePicItemAdapter = new GvAddStepPricesTypeProfilePicItemAdapter(this, profilePicList, new Callback() {
			@Override
			public void notice(int position) {
				if (canEdit) {//如果待审核等状态照片不能再编辑
					picIndex = position;
					if (position == (profilePicList.size() - 1)) {//第一次点击或者点的是最后一个


						Intent intent = new Intent(AddGoodsStepTwoActivityOLD.this, SelectPictureActivity.class);
						startActivityForResult(intent, REQUEST_GET_PHOTO);
						overridePendingTransition(R.anim.bottom_push_in, R.anim.bottom_push_out);

					} else {
						createDialog(position);
					}
				}
			}
		});
		gvAddStepPricesTypeProfilePic.setAdapter(gvAddStepPricesTypeProfilePicItemAdapter);



		//服务器获取信息
		new CategoryAttrModel(this, new OnNetBackListener<CategoryAttrBean>() {
			@Override
			public void netBack(CategoryAttrBean data) {
				if (data == null) {
					Toast.makeText(AddGoodsStepTwoActivityOLD.this, data.getMsg(), Toast.LENGTH_SHORT).show();
				} else {
					if (data.getStatus() == 1) {
						categoryAttrBean = data;
						initDealData();
						initViewData();
					} else {
						//没有分类属性 添加一个货物图样
						profilePicList.add("");
						gvAddStepPricesTypeProfilePicItemAdapter.notifyDataSetChanged();
						Toast.makeText(AddGoodsStepTwoActivityOLD.this, data.getMsg(), Toast.LENGTH_SHORT).show();
					}
				}
			}
		}).request(JSONUtil.toJSON(new ReadAddGoodsStepTwoSubmitBean(objectId)), true);
      /*  if (releaseGoodsState == 1) {//发布商品进入的
            new CategoryAttrModel(this, new OnNetBackListener<CategoryAttrBean>() {
                @Override
                public void netBack(CategoryAttrBean data) {
                    if (data == null) {
                        Toast.makeText(AddGoodsStepTwoActivity.this, data.getMsg(), Toast.LENGTH_SHORT).show();
                    } else {
                        if (data.getStatus() == 1) {
                            categoryAttrBean = data;
                            initDealData();
                            initViewData();
                        } else {
                            Toast.makeText(AddGoodsStepTwoActivity.this, data.getMsg(), Toast.LENGTH_SHORT).show();
                        }
                    }
                }
            }).request(JSONUtil.toJSON(new ReadAddGoodsStepTwoSubmitBean(objectId)), true);//.request(JSONUtil.toJSON(new CategoryAttrSubmitBean(catId)), true);

        }else  if (releaseGoodsState == 3) {//点击详情进入的 也就是重新编辑进入的
              //这里需要修改 从网路获取已经提交过的信息，如果没有信息 则显示默认的


            new CategoryAttrModel(this, new OnNetBackListener<CategoryAttrBean>() {
                @Override
                public void netBack(CategoryAttrBean data) {
                    if (data == null) {
                        Toast.makeText(AddGoodsStepTwoActivity.this, data.getMsg(), Toast.LENGTH_SHORT).show();
                    } else {
                        if (data.getStatus() == 1) {
                            categoryAttrBean = data;
                            initDealData();
                            initViewData();
                        } else {
                            Toast.makeText(AddGoodsStepTwoActivity.this, data.getMsg(), Toast.LENGTH_SHORT).show();
                        }
                    }
                }
            }).request(JSONUtil.toJSON(new ReadAddGoodsStepTwoSubmitBean(objectId)), true);//.request(JSONUtil.toJSON(new CategoryAttrSubmitBean(catId)), true);


        }*/


	}

	private void initDealData() {
		List<CategoryAttrBean.ResBean.AttrBean> resList = categoryAttrBean.getRes().getAttr();
		if (addTo != 1) {
			for (CategoryAttrBean.ResBean.AttrBean rb : resList) {
				if ("1".equals(rb.getAttr_type())) {
					resTypeOne.add(rb);
				} else if ("3".equals(rb.getAttr_type())) {
					resTypeThree.add(rb);
				} else if ("4".equals(rb.getAttr_type())) {
					resTypeFour.add(rb);
				} else if ("5".equals(rb.getAttr_type())) {
					resTypeFive.add(rb);
				}
			}
		} else {//如果是拍卖 单选变下拉
			for (CategoryAttrBean.ResBean.AttrBean rb : resList) {
				if ("1".equals(rb.getAttr_type())) {
					resTypeOne.add(rb);
				} else if ("4".equals(rb.getAttr_type())) {
					resTypeFour.add(rb);
				} else if ("5".equals(rb.getAttr_type()) || "3".equals(rb.getAttr_type())) {
					resTypeFive.add(rb);
				}
			}
		}
	}

	@Override
	public void onBackPressed() {
		finishForBack();
	}


	private void initViewData() {

		//adapter 设置
		//文本的
		mllAddStepPricesTypeOneItemAdapter = new MllAddStepPricesTypeOneItemAdapter(this, resTypeOne);
		mllAddStepPricesTypeOne.setAdapter(mllAddStepPricesTypeOneItemAdapter);
		if (resTypeOne.size()<=0){
			mllAddStepPricesTypeOne.setVisibility(View.GONE);
		}else{
			mllAddStepPricesTypeOne.setVisibility(View.VISIBLE);
		}
		//单选的
		mllAddStepPricesTypeThreeItemAdapter = new MllAddStepPricesTypeThreeItemAdapter(this, resTypeThree);
		mllAddStepPricesTypeThree.setAdapter(mllAddStepPricesTypeThreeItemAdapter);
		if (resTypeThree.size()<=0){
			mllAddStepPricesTypeThree.setVisibility(View.GONE);
		}else{
			mllAddStepPricesTypeThree.setVisibility(View.VISIBLE);
		}
		//多选的
		mllAddStepPricesTypeFourItemAdapter = new MllAddStepPricesTypeFourItemAdapter(this, resTypeFour);
		mllAddStepPricesTypeFour.setAdapter(mllAddStepPricesTypeFourItemAdapter);
		if (resTypeFour.size()<=0){
			mllAddStepPricesTypeFour.setVisibility(View.GONE);
		}else{
			mllAddStepPricesTypeFour.setVisibility(View.VISIBLE);
		}
		//下拉的

		//给下拉赋值默认值 cont 默认显示第一个
		for (int i = 0; i < resTypeFive.size(); i++) {
			if (resTypeFive.get(i).getDefault_value().size() > 0) {
				resTypeFive.get(i).setContent(resTypeFive.get(i).getDefault_value().get(0).getValue());
				//更新提交参数中修改的这个参数
				for (int j = 0; j < resTypeFive.get(i).getAttr_values().size(); j++) {
					if (resTypeFive.get(i).getAttr_values().get(j).getId() == resTypeFive.get(i).getDefault_value().get(0).getId()) {
						resTypeFive.get(i).getAttr_values().get(j).setChecked(true);//此项目被选中
					}
				}
			} else {//不存在默认值，则显示第一个的值
				resTypeFive.get(i).setContent(resTypeFive.get(i).getAttr_values().get(0).getValue());
				//更新提交参数中修改的这个参数
				resTypeFive.get(i).getAttr_values().get(0).setChecked(true);//此项目被选中
			}
		}

		mllAddStepPricesTypeFiveItemAdapter = new MllAddStepPricesTypeFiveItemAdapter(this, resTypeFive, mllAddStepPricesTypeFiveItemAdapterOnClickListener);
		mllAddStepPricesTypeFive.setAdapter(mllAddStepPricesTypeFiveItemAdapter);
		if (resTypeFive.size()<=0){
			mllAddStepPricesTypeFive.setVisibility(View.GONE);
		}else{
			mllAddStepPricesTypeFive.setVisibility(View.VISIBLE);
		}
		//货物图样
		//这里需要修改 这里没有返回的 profilePic货物图样的图片id集合字段 已经修改
		profilePic = categoryAttrBean.getRes().getProfilePic();
		if (null == profilePic || "".equals(profilePic)) {
			profilePic = "";
			profilePicList.add("");//刚进去默认有一张图片

		} else {
			//说明之前保存过 从网络中获取图片地址

			profilePicList.clear();
			//从网络获取 给picList赋值，同时添加一个空值
			getImageInfoFromIn();

		}




	}

	private void getImageInfoFromIn() {
		GetImageInfoSubmitBean getImageInfoSubmitBean = new GetImageInfoSubmitBean();
		getImageInfoSubmitBean.setIds(profilePic);
		GetImageInfoModel getImageInfoModel = new GetImageInfoModel(this, new OnNetBackListener<GetImageInfoBean>() {
			@Override
			public void netBack(GetImageInfoBean data) {
				if (data == null) {
					Toast.makeText(AddGoodsStepTwoActivityOLD.this, data.getMsg(), Toast.LENGTH_SHORT).show();
				} else {
					if (data.getStatus() == 1) {
						for (GetImageInfoBean.ResBean resBean : data.getRes()) {
							profilePicList.add(HttpApi.BANNERUTL + resBean.getUrl());
						}
						profilePicList.add("");
						gvAddStepPricesTypeProfilePicItemAdapter.notifyDataSetChanged();
					} else {

						Toast.makeText(AddGoodsStepTwoActivityOLD.this, data.getMsg(), Toast.LENGTH_SHORT).show();
					}
				}
			}
		});
		getImageInfoModel.request(JSONUtil.toJSON(getImageInfoSubmitBean), true);

	}


	@Override
	public void onActivityResult(int requestCode, int resultCode, Intent data) {
		super.onActivityResult(requestCode, resultCode, data);
		if (resultCode == RESULT_OK) {
			switch (requestCode) {
				case REQUEST_GET_PHOTO:
					String picturePath = data.getStringExtra("path");
					profilePicList.set(picIndex, picturePath);
					//上传图片
					uploadPicture(picIndex + ".png", picturePath);
					//添加一个新的空的照片
					profilePicList.add("");
					gvAddStepPricesTypeProfilePicItemAdapter.notifyDataSetChanged();
					break;
				default:
					break;
			}
		}
	}

	private void uploadPicture(String type, String picturePath) {
		if (uploadPicturesModel == null) {
			uploadPicturesModel = new UploadPicturesModel(this, new OnNetBackListener<UploadPicturesBean>() {
				@Override
				public void netBack(UploadPicturesBean data) {
					if (data == null) {
						Toast.makeText(AddGoodsStepTwoActivityOLD.this, "上传失败", Toast.LENGTH_SHORT).show();
						return;
					}

					if (data.getStatus().equals("1")) {
						String id = data.getRes().getArr().get(0).getId();
						if (TextUtils.isEmpty(profilePic)) {
							profilePic = id;
						} else {
							profilePic = profilePic + "," + id;
						}
						Utils.showLog("=======货物图样添加后profilePic：" + profilePic);
					} else {
						Toast.makeText(AddGoodsStepTwoActivityOLD.this, data.getMsg(), Toast.LENGTH_SHORT).show();
					}
				}
			});
		}
		Map<String, String> map = new HashMap<>();
		map.put(type, picturePath);
		uploadPicturesModel.request(map, true);
	}

	private void createDialog(final int position) {
		AlertDialog dialog;
		AlertDialog.Builder builder = new AlertDialog.Builder(this);
		builder.setMessage("确认删除吗?");
		builder.setPositiveButton("确认", new DialogInterface.OnClickListener() {
			@Override
			public void onClick(DialogInterface dialog, int which) {
				dialog.dismiss();
				profilePicList.remove(position);
				//从storePic中去除
				if (TextUtils.isEmpty(profilePic)) {
					profilePic = "";
				} else {
					String[] sp = profilePic.split(",");
					sp[position] = null;
					profilePic = "";
					for (int i = 0; i < sp.length; i++) {
						if (sp[i] != null) {
							if ("".equals(profilePic)) {
								profilePic = sp[i];
							} else {
								profilePic = profilePic + "," + sp[i];
							}
						}
					}
				}
				//
				Utils.showLog("=======货物图样删除后profilePic：" + profilePic);
				gvAddStepPricesTypeProfilePicItemAdapter.notifyDataSetChanged();

			}
		});
		builder.setNegativeButton("取消", new DialogInterface.OnClickListener() {
			@Override
			public void onClick(DialogInterface dialog, int which) {
				dialog.dismiss();
			}
		});
		dialog = builder.create();
		dialog.show();
	}

	@Override
	protected void initListener() {
		title_right_tv.setOnClickListener(this);
		title_left_tv.setOnClickListener(this);
		backIv.setOnClickListener(this);
	}

	@Override
	protected void init() {
		titleTv.setText("附加信息");
		backIv.setVisibility(View.VISIBLE);
		title_right_tv.setVisibility(View.VISIBLE);
		title_right_tv.setText("下一步");
		title_left_tv.setText("上一步");
		title_left_tv.setVisibility(View.VISIBLE);
	}

	private void finishForBack() {
		Intent intent = new Intent();
		intent.putExtra("addTo", addTo);
		intent.putExtra("catId", catId);
		intent.putExtra("objectId", objectId);
		intent.putExtra("releaseGoodsState", releaseGoodsState);
		setResult(ReleaseGoodsActivity.STEP_TWO_RESULT_CODE, intent);
		Utils.showLog("===返回编辑的时候提交的releaseGoodsState：" + releaseGoodsState);
		finish();
	}

	@Override
	public void onClick(View v) {
		switch (v.getId()) {
			case R.id.title_left_img:
				finishForBack();
				break;
			case R.id.title_left_tv:
				finishForBack();
				break;
			case R.id.title_right_tv://下一步
				if (canEdit) {
					getPickData();
					//打印一下
					for (AddGoodsStepTwoSubmitBean.AttrValueBean avb : addGoodsStepTwoSubmitBean.getAttrValue()) {
						Utils.showLog("=====" + avb.getAttrId() + " " + avb.getValue() + " " + avb.getChangePrice());
					}

               /* //测试退出 直接跳转到卖家中心
                AppManager appManager =AppManager.getAppManager();

                appManager.toSeller();*/

					addGoodsStepTwoSubmitBean.setObjectId(objectId);
					addGoodsStepTwoSubmitBean.setType("goods");
					addGoodsStepTwoSubmitBean.setProfilePic(profilePic);
					new AddGoodsStepTwoModel(this, new OnNetBackListener<Bean>() {
						@Override
						public void netBack(Bean data) {
							if (data == null) {
								Toast.makeText(AddGoodsStepTwoActivityOLD.this, data.getMsg(), Toast.LENGTH_SHORT).show();
							} else {
								if ("1".equals(data.getStatus())) {//正确添加 附加信息 进入第三步
									Intent intent = new Intent();
									intent.setClass(AddGoodsStepTwoActivityOLD.this, AddGoodsStepThreeActivity.class);
									intent.putExtra("objectId", objectId);
									startActivity(intent);


									Toast.makeText(AddGoodsStepTwoActivityOLD.this, data.getMsg(), Toast.LENGTH_SHORT).show();
								} else {
									Toast.makeText(AddGoodsStepTwoActivityOLD.this, data.getMsg(), Toast.LENGTH_SHORT).show();
								}
							}
						}
					}).request(JSONUtil.toJSON(addGoodsStepTwoSubmitBean), true);
				} else {
					Intent intent = new Intent();
					intent.setClass(AddGoodsStepTwoActivityOLD.this, AddGoodsStepThreeActivity.class);
					intent.putExtra("objectId", objectId);
					startActivity(intent);
				}
				break;
			default:
				break;
		}
	}

	/**
	 * 获取选中的值，赋值到submitBean中
	 */
	private void getPickData() {
		addGoodsStepTwoSubmitBean.getAttrValue().clear();//充值


		for (CategoryAttrBean.ResBean.AttrBean rb : resTypeOne) {
			for (CategoryAttrBean.ResBean.AttrBean.AttrValuesBean avb : rb.getAttr_values()) {
				// if (avb.isChecked()) {文本不管修改不修改都保存
				Utils.showLog("=====avbresTypeOne:" + avb.getId() + " " + avb.getValue() + "  " + avb.getChangePrice());
				AddGoodsStepTwoSubmitBean.AttrValueBean avbForSubmit = new AddGoodsStepTwoSubmitBean.AttrValueBean();
				avbForSubmit.setAttrId(rb.getId());
				avbForSubmit.setValue(avb.getValue());
				avbForSubmit.setChangePrice(avb.getChangePrice());
				addGoodsStepTwoSubmitBean.getAttrValue().add(avbForSubmit);
				// }
			}
		}
		for (CategoryAttrBean.ResBean.AttrBean rb : resTypeThree) {
			for (CategoryAttrBean.ResBean.AttrBean.AttrValuesBean avb : rb.getAttr_values()) {
				if (avb.isChecked()) {
					Utils.showLog("=====avbresTypeThree:" + avb.getId() + " " + avb.getValue() + "  " + avb.getChangePrice());
					AddGoodsStepTwoSubmitBean.AttrValueBean avbForSubmit = new AddGoodsStepTwoSubmitBean.AttrValueBean();
					avbForSubmit.setAttrId(rb.getId());
					avbForSubmit.setValue(avb.getValue());
					avbForSubmit.setChangePrice(avb.getChangePrice());
					addGoodsStepTwoSubmitBean.getAttrValue().add(avbForSubmit);
				}
			}
		}
		for (CategoryAttrBean.ResBean.AttrBean rb : resTypeFour) {
			for (CategoryAttrBean.ResBean.AttrBean.AttrValuesBean avb : rb.getAttr_values()) {
				if (avb.isChecked()) {
					Utils.showLog("=====avbresTypeFour:" + avb.getId() + " " + avb.getValue() + "  " + avb.getChangePrice());
					AddGoodsStepTwoSubmitBean.AttrValueBean avbForSubmit = new AddGoodsStepTwoSubmitBean.AttrValueBean();
					avbForSubmit.setAttrId(rb.getId());
					avbForSubmit.setValue(avb.getValue());
					avbForSubmit.setChangePrice(avb.getChangePrice());
					addGoodsStepTwoSubmitBean.getAttrValue().add(avbForSubmit);
				}
			}
		}
		for (CategoryAttrBean.ResBean.AttrBean rb : resTypeFive) {
			for (CategoryAttrBean.ResBean.AttrBean.AttrValuesBean avb : rb.getAttr_values()) {
				if (avb.isChecked()) {
					Utils.showLog("=====avbresTypeFive:" + avb.getId() + " " + avb.getValue() + "  " + avb.getChangePrice());
					AddGoodsStepTwoSubmitBean.AttrValueBean avbForSubmit = new AddGoodsStepTwoSubmitBean.AttrValueBean();
					avbForSubmit.setAttrId(rb.getId());
					avbForSubmit.setValue(avb.getValue());
					avbForSubmit.setChangePrice(avb.getChangePrice());
					addGoodsStepTwoSubmitBean.getAttrValue().add(avbForSubmit);
				}
			}
		}
	}

	final List<OneModel> oneModelList = new ArrayList<OneModel>();//滚轮一级
	public SkmModiPopup skmModiPopup;
	int positionItem = 0;//选择的第几条附加值

	private void showPop() {
		skmModiPopup = new SkmModiPopup(this, skmPopOnClickListener, oneModelList, "选择", 1, null);
		skmModiPopup.showAtLocation(findViewById(R.id.rl_release_goods_step_two),
				Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL, 0, 0);
	}

	public SkmModiPopup.SkmPopOnClickListener skmPopOnClickListener = new SkmModiPopup.SkmPopOnClickListener() {

		@Override
		public void myOnClick(int pOneCurrent, int pTwoCurrent, int pThreeCurrent, View v, View root) {
			skmModiPopup.dismiss();
			Utils.showLog("========SkmPopOnClickListener positionItem=" + positionItem + " pOneCurrent=" + pOneCurrent + " oneModelListForGoodsClassify.size" + oneModelList.size());

			//Toast.makeText(MallOrderActivity.this, getGoods_attrs.get(positionItem).getDefault_value().get(pOneCurrent) + "  " + getGoods_attrs.get(positionItem).getId(), Toast.LENGTH_SHORT).show();

			// 重置是否选中

			for (int i = 0; i < resTypeFive.get(positionItem).getAttr_values().size(); i++) {
				resTypeFive.get(positionItem).getAttr_values().get(i).setChecked(false);
			}

			//更新提交参数中修改的这个参数
			resTypeFive.get(positionItem).getAttr_values().get(pOneCurrent).setChecked(true);//此项目被选中


			//更改content值 这个字段 如果重新生成bean要重新写上去
			resTypeFive.get(positionItem).setContent(resTypeFive.get(positionItem).getAttr_values().get(pOneCurrent).getValue());

			mllAddStepPricesTypeFiveItemAdapter.notifyDataSetChanged();

		}
	};
	//adapter回调
	MllAddStepPricesTypeFiveItemAdapter.MllAddStepPricesTypeFiveItemAdapterOnClickListener mllAddStepPricesTypeFiveItemAdapterOnClickListener = new MllAddStepPricesTypeFiveItemAdapter.MllAddStepPricesTypeFiveItemAdapterOnClickListener() {
		@Override
		public void myOnClick(int position) {
			positionItem = position;
			oneModelList.clear();
			for (int i = 0; i < resTypeFive.get(positionItem).getAttr_values().size(); i++) {

				OneModel oneModel = new OneModel();
				oneModel.setId(resTypeFive.get(positionItem).getAttr_values().get(i).getId() + "");//属性的id
				oneModel.setName(resTypeFive.get(positionItem).getAttr_values().get(i).getValue());//属性的值
				oneModelList.add(oneModel);
			}
			showPop();
		}
	};
}
